<?php
$serverpath=$_SERVER['DOCUMENT_ROOT'];
include ($serverpath.'/Classes/session.php');
$filename=$serverpath.'/files/users.txt';
$file = fopen($filename,"r");
$succesfull=false;
$user = $_POST['userName'];
$password = $_POST['password'];

while (!feof($file)) {
		$line=fgets($file);
		$info = explode('|',$line);

		if ((ltrim ($info[1])==$user)&&(ltrim($info[2])==$password)){
			//Creo la Session
			$session = new session($info[0],$info[1]);
			$serialize_session = serialize($session);
			file_put_contents('store_session',$serialize_session);
			fclose($file);
			header('Location: home.php');
		}
	}
	header('Location: index.html');
	fclose($file);
?>